import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmployeeVO, EmployeeForm, EmployeeQuery } from '@/api/employee/types';

/**
 * 查询员工信息列表
 * @param query
 * @returns {*}
 */

export const listEmployee = (query?: EmployeeQuery): AxiosPromise<EmployeeVO[]> => {
  return request({
    url: '/admin/employee/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询员工信息详细
 * @param id
 */
export const getEmployee = (id: string | number): AxiosPromise<EmployeeVO> => {
  return request({
    url: '/admin/employee/' + id,
    method: 'get'
  });
};

/**
 * 新增员工信息
 * @param data
 */
export const addEmployee = (data: EmployeeForm) => {
  return request({
    url: '/admin/employee',
    method: 'post',
    data: data
  });
};

/**
 * 修改员工信息
 * @param data
 */
export const updateEmployee = (data: EmployeeForm) => {
  return request({
    url: '/company/employee',
    method: 'put',
    data: data
  });
};

/**
 * 删除员工信息
 * @param id
 */
export const delEmployee = (id: string | number | Array<string | number>) => {
  return request({
    url: '/admin/employee/' + id,
    method: 'delete'
  });
};

/**
 * 查询我的员工信息列表
 * @param query
 * @returns {*}
 */
export const listMyEmployee = (query) => {
  return request({
    url: '/company/employee/myList',
    method: 'get',
    params: query
  });
};


/**
 * 注册员工
 * @param data
 */
export const registerEmployee = (data: EmployeeForm) => {
  return request({
    url: '/company/registerEmployee',
    method: 'post',
    data: data
  });
};
